/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on Oct 30, 2011, 11:58:51 PM
 */

package giormi;

import javax.swing.JTable;

/**
 *
 * @author Ling
 */
public class MainFrame extends javax.swing.JFrame {

    private int p_row = -1, s_row = -1, o_row = -1, c_row = -1;
    private Integer oitemid;
    private int itemid;
    /** Creates new form MainFrame */
    public MainFrame() {
        initComponents();
        this.setLocation(20, 20);
        this.setSize(1240, 700);
        this.setResizable(false);
        this.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);

        ordersTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        stocksTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);

        manageproductsPanel.setVisible(true);
        managestocksPanel.setVisible(false);
        manageordersPanel.setVisible(false);
        managecustomersPanel.setVisible(false);

        viewProducts view = new viewProducts(this.productsTable);
        view.connect();
        view.viewProducts();
        view.disconnect();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        exitButton = new javax.swing.JButton();
        manageproductsButton = new javax.swing.JButton();
        managestocksButton = new javax.swing.JButton();
        manageordersButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        manageproductsPanel = new javax.swing.JPanel();
        addproductButton = new javax.swing.JButton();
        updateproductButton = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        productsTable = new javax.swing.JTable();
        searchproductsPanel = new javax.swing.JPanel();
        searchproductButton = new javax.swing.JButton();
        productsearchField = new javax.swing.JTextField();
        activeproductsCheckbox = new javax.swing.JCheckBox();
        jLabel10 = new javax.swing.JLabel();
        presetButton = new javax.swing.JButton();
        managecustomersPanel = new javax.swing.JPanel();
        updatecustomerButton = new javax.swing.JButton();
        searchcustomersPanel = new javax.swing.JPanel();
        searchcustomerButton = new javax.swing.JButton();
        customersearchField = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        c_resetButton = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        customersTable = new javax.swing.JTable();
        addcustomerButton = new javax.swing.JButton();
        managestocksPanel = new javax.swing.JPanel();
        addstockButton = new javax.swing.JButton();
        updatestockButton = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        stocksTable = new javax.swing.JTable();
        searchstocksPanel = new javax.swing.JPanel();
        stocksearchCombox = new javax.swing.JComboBox();
        s_searchButton = new javax.swing.JButton();
        s_dwindlingButton = new javax.swing.JButton();
        s_resetButton = new javax.swing.JButton();
        datestocksearchField = new datechooser.beans.DateChooserCombo();
        stocksearchField = new javax.swing.JTextField();
        manageordersPanel = new javax.swing.JPanel();
        addorderButton = new javax.swing.JButton();
        updateorderButton = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        ordersTable = new javax.swing.JTable();
        searchordersPanel = new javax.swing.JPanel();
        searchorderCombox = new javax.swing.JComboBox();
        o_searchButton = new javax.swing.JButton();
        o_resetButton = new javax.swing.JButton();
        o_startdateField = new datechooser.beans.DateChooserCombo();
        ordersearchField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        managecustomersButton = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Gior-Mi Marketing Corporation Inventory System");
        setMinimumSize(new java.awt.Dimension(1240, 557));
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        exitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Log-Out-icon.png"))); // NOI18N
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });
        getContentPane().add(exitButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 570, 100, 80));

        manageproductsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/canned-food-icon copy.png"))); // NOI18N
        manageproductsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                manageproductsButtonActionPerformed(evt);
            }
        });
        getContentPane().add(manageproductsButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, 100, 80));

        managestocksButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/shopping-basket-full-icon copy.png"))); // NOI18N
        managestocksButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                managestocksButtonActionPerformed(evt);
            }
        });
        getContentPane().add(managestocksButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 210, 100, 80));

        manageordersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Clipboard-Paste-icon.png"))); // NOI18N
        manageordersButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                manageordersButtonActionPerformed(evt);
            }
        });
        getContentPane().add(manageordersButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 320, 100, 80));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Exit");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 650, 100, -1));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Manage Products");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 100, -1));

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Manage Stocks");
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 290, 100, -1));

        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Manage Orders");
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 400, 100, -1));

        manageproductsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Manage Products"));
        manageproductsPanel.setMinimumSize(new java.awt.Dimension(1100, 560));
        manageproductsPanel.setPreferredSize(new java.awt.Dimension(1100, 560));
        manageproductsPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        addproductButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Add-icon.png"))); // NOI18N
        addproductButton.setText("Add");
        addproductButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addproductButtonActionPerformed(evt);
            }
        });
        manageproductsPanel.add(addproductButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, 170, 50));

        updateproductButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Pen-Green-icon.png"))); // NOI18N
        updateproductButton.setText("Update");
        updateproductButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateproductButtonActionPerformed(evt);
            }
        });
        manageproductsPanel.add(updateproductButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 470, 170, 50));

        productsTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1000", "Heng Bing Whole Mushroom", "200g.", "6901009018819", "Active", "24 x 400 g."},
                {"1001", "Heng Bing Straw Mushroom", "200g.", "6901009018840", "Active", "24 x 400 g."},
                {"1002", "Heng Bing Pieces and Stem Mushroom", "200g.", "6901009018888", "Active", "24 x 400 g."},
                {"1003", "Heng Bing Pieces and Stem Mushroom", "525g", "6901009386666", "Active", "24 x 800 g."},
                {"1004", "Heng Bing Oyster Sauce ", null, "6922532889417", "Inactive", "12 x 5 lbs."},
                {"1005", "Heng Bing Oyster Sauce ", null, "6922532815690", "Active", "12 x 750 g."},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Product No.", "Product Name", "Net Weight", "Barcode", "Status", "Packing"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        productsTable.setPreferredSize(new java.awt.Dimension(1210, 450));
        jScrollPane6.setViewportView(productsTable);
        productsTable.getColumnModel().getColumn(1).setPreferredWidth(350);

        manageproductsPanel.add(jScrollPane6, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 1020, 330));

        searchproductsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search Product"));
        searchproductsPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        searchproductButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Zoom-icon (1).png"))); // NOI18N
        searchproductButton.setText("Search");
        searchproductButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchproductButtonActionPerformed(evt);
            }
        });
        searchproductsPanel.add(searchproductButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 60, 130, -1));
        searchproductsPanel.add(productsearchField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 320, -1));

        activeproductsCheckbox.setText("Show \"Active\" products only");
        searchproductsPanel.add(activeproductsCheckbox, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 90, -1, -1));

        jLabel10.setText("by Product Name");
        searchproductsPanel.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, 150, 30));

        presetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Reload-icon.png"))); // NOI18N
        presetButton.setText("Reset View");
        presetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                presetButtonActionPerformed(evt);
            }
        });
        searchproductsPanel.add(presetButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 90, 130, -1));

        manageproductsPanel.add(searchproductsPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 400, 560, 130));

        getContentPane().add(manageproductsPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 95, 1100, 560));

        managecustomersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Manage Customers"));
        managecustomersPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        updatecustomerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Pen-Green-icon.png"))); // NOI18N
        updatecustomerButton.setText("Update");
        updatecustomerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updatecustomerButtonActionPerformed(evt);
            }
        });
        managecustomersPanel.add(updatecustomerButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 470, 170, 50));

        searchcustomersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search Customer"));
        searchcustomersPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        searchcustomerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Zoom-icon (1).png"))); // NOI18N
        searchcustomerButton.setText("Search");
        searchcustomerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchcustomerButtonActionPerformed(evt);
            }
        });
        searchcustomersPanel.add(searchcustomerButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 60, 140, -1));
        searchcustomersPanel.add(customersearchField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 320, -1));

        jLabel11.setText("by Customer Name");
        searchcustomersPanel.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, 150, 30));

        c_resetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Reload-icon.png"))); // NOI18N
        c_resetButton.setText("Reset View");
        c_resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                c_resetButtonActionPerformed(evt);
            }
        });
        searchcustomersPanel.add(c_resetButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(380, 90, 140, -1));

        managecustomersPanel.add(searchcustomersPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 400, 540, 130));

        customersTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1000", "Cash and Carry"},
                {"1001", "Unimart"},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Customer No.", "Customer Name"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(customersTable);
        customersTable.getColumnModel().getColumn(0).setResizable(false);
        customersTable.getColumnModel().getColumn(1).setResizable(false);

        managecustomersPanel.add(jScrollPane5, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 1020, 330));

        addcustomerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Add-icon.png"))); // NOI18N
        addcustomerButton.setText("Add");
        addcustomerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addcustomerButtonActionPerformed(evt);
            }
        });
        managecustomersPanel.add(addcustomerButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, 170, 50));

        getContentPane().add(managecustomersPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 95, 1100, 560));

        managestocksPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Manage Stocks"));
        managestocksPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        addstockButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Add-icon.png"))); // NOI18N
        addstockButton.setText("Add");
        addstockButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addstockButtonActionPerformed(evt);
            }
        });
        managestocksPanel.add(addstockButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, 170, 50));

        updatestockButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Pen-Green-icon.png"))); // NOI18N
        updatestockButton.setText("Update");
        updatestockButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updatestockButtonActionPerformed(evt);
            }
        });
        managestocksPanel.add(updatestockButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 470, 170, 50));

        stocksTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1000", "10-13-11", "10-10-11", "400", "380", "Heng Bing Whole Mushroom", "24 x 400 g.", "200g.", "Active", "6901009018819", "554011", "001720", "12-25-10", "12-25-13", "4301", null},
                {"1001", "10-13-11", "10-10-11", "200", "130", "Heng Bing Straw Mushroom", "24 x 400 g.", "200g.", "Active", "6901009018840", "554011", "001720", "12-25-10", "12-25-13", "1251", null},
                {"1002", "10-13-11", "10-10-11", "350", "300", "Heng Bing Pieces and Stem Mushroom", "24 x 400 g.", "200g.", "Active", "6901009018888", "554011", "001720", "12-25-10", "12-25-13", "305", null},
                {"1003", "10-13-11", "10-12-11", "100", "0", "Heng Bing Pieces and Stem Mushroom", "24 x 800 g.", "525g.", "Active", "6901009386666", "554011", "001720", "12-25-10", "12-25-13", "2512", null},
                {"1004", "10-13-11", "10-12-11", "50", "0", "Heng Bing Oyster Sauce ", "12 x 5 lbs.", null, "Inactive", "6922532889417", "554011", "001720", "12-25-10", "12-25-13", "625", null},
                {"1005", "10-13-11", "10-12-11", "50", "0", "Heng Bing Oyster Sauce ", null, null, "Active", "6922532815690", "554011", "001720", "12-25-10", "12-25-13", "562", null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Stock No.", "Date Posted", "Receiving Date", "Total Qty.", "Balance", "Product Name", "Packing", "Net Weight", "Status", "Barcode", "Quedan", "RR No.", "Production Date", "Expiry Date", "Lot No.", "Notes"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        stocksTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        stocksTable.setPreferredSize(new java.awt.Dimension(1510, 450));
        jScrollPane2.setViewportView(stocksTable);
        stocksTable.getColumnModel().getColumn(0).setPreferredWidth(80);
        stocksTable.getColumnModel().getColumn(1).setPreferredWidth(100);
        stocksTable.getColumnModel().getColumn(2).setPreferredWidth(130);
        stocksTable.getColumnModel().getColumn(3).setPreferredWidth(90);
        stocksTable.getColumnModel().getColumn(4).setPreferredWidth(90);
        stocksTable.getColumnModel().getColumn(5).setPreferredWidth(300);
        stocksTable.getColumnModel().getColumn(6).setPreferredWidth(100);
        stocksTable.getColumnModel().getColumn(7).setPreferredWidth(100);
        stocksTable.getColumnModel().getColumn(8).setPreferredWidth(100);
        stocksTable.getColumnModel().getColumn(9).setPreferredWidth(150);
        stocksTable.getColumnModel().getColumn(10).setPreferredWidth(90);
        stocksTable.getColumnModel().getColumn(11).setPreferredWidth(90);
        stocksTable.getColumnModel().getColumn(12).setPreferredWidth(120);
        stocksTable.getColumnModel().getColumn(13).setPreferredWidth(120);
        stocksTable.getColumnModel().getColumn(14).setPreferredWidth(100);
        stocksTable.getColumnModel().getColumn(15).setPreferredWidth(200);

        managestocksPanel.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 1020, 330));

        searchstocksPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search Stock"));
        searchstocksPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        stocksearchCombox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "by Product Name", "by Date Posted" }));
        stocksearchCombox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stocksearchComboxActionPerformed(evt);
            }
        });
        searchstocksPanel.add(stocksearchCombox, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, 140, -1));

        s_searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Zoom-icon (1).png"))); // NOI18N
        s_searchButton.setText("Search");
        s_searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                s_searchButtonActionPerformed(evt);
            }
        });
        searchstocksPanel.add(s_searchButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 60, 140, -1));

        s_dwindlingButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Document-Preview-icon (1).png"))); // NOI18N
        s_dwindlingButton.setText("View Dwindling Stocks");
        s_dwindlingButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                s_dwindlingButtonActionPerformed(evt);
            }
        });
        searchstocksPanel.add(s_dwindlingButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 90, 190, -1));

        s_resetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Reload-icon.png"))); // NOI18N
        s_resetButton.setText("Reset View");
        s_resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                s_resetButtonActionPerformed(evt);
            }
        });
        searchstocksPanel.add(s_resetButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 90, 140, -1));

        datestocksearchField.setWeekStyle(datechooser.view.WeekDaysStyle.SHORT);
        searchstocksPanel.add(datestocksearchField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, -1, -1));
        searchstocksPanel.add(stocksearchField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 320, -1));

        managestocksPanel.add(searchstocksPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 400, 570, 130));

        getContentPane().add(managestocksPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 95, 1100, 560));

        manageordersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Manage Orders"));
        manageordersPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        addorderButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Add-icon.png"))); // NOI18N
        addorderButton.setText("Add");
        addorderButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addorderButtonActionPerformed(evt);
            }
        });
        manageordersPanel.add(addorderButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 410, 170, 50));

        updateorderButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Pen-Green-icon.png"))); // NOI18N
        updateorderButton.setText("Update");
        updateorderButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateorderButtonActionPerformed(evt);
            }
        });
        manageordersPanel.add(updateorderButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 470, 170, 50));

        ordersTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1000", "10-31-11", "Cash and Carry", "Heng Bing Whole Mushroom", "24 x 400 g.", "554011", "20", "0", "10-22-11", "10-22-11", "3756", "001438", "58432", null},
                {"1001", "10-31-11", "Cash and Carry", "Heng Bing Straw Mushroom", "24 x 400 g.", "554011", "70", "0", "10-22-11", "10-22-11", "3756", "001438", "58432", null},
                {"1002", "10-31-11", "Cash and Carry", "Heng Bing Pieces and Stem Mushroom", "24 x 400 g.", "554011", "50", "0", "10-22-11", "10-22-11", "3756", "001438", "58432", null},
                {"1003", "10-31-11", "Unimart", "Heng Bing Pieces and Stem Mushroom", "24 x 800 g.", "554011", "100", "32", "10-28-11", "10-28-11", "3758", "001442", "58450", null},
                {"1004", "10-31-11", "Unimart", "Heng Bing Oyster Sauce ", "12 x 5 lbs.", "554011", "50", "0", "10-28-11", "10-28-11", "3758", "001442", "58450", null},
                {"1005", "10-31-11", "Unimart", "Heng Bing Oyster Sauce ", "12 x 750 g.", "554011", "50", "16", "10-28-11", "10-28-11", "3758", "001442", "58450", null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Order No.", "Date Posted", "Customer Name", "Product Name", "Packing", "Quedan", "Qty. Sold", "Qty. Returned", "Delivery Date", "DR Date", "DR No.", "Withdrawal Slip No.", "Warehouse Releasing No.", "Notes"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        ordersTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        ordersTable.setPreferredSize(new java.awt.Dimension(1510, 450));
        jScrollPane4.setViewportView(ordersTable);
        ordersTable.getColumnModel().getColumn(0).setResizable(false);
        ordersTable.getColumnModel().getColumn(0).setPreferredWidth(120);
        ordersTable.getColumnModel().getColumn(1).setResizable(false);
        ordersTable.getColumnModel().getColumn(1).setPreferredWidth(150);
        ordersTable.getColumnModel().getColumn(2).setResizable(false);
        ordersTable.getColumnModel().getColumn(2).setPreferredWidth(200);
        ordersTable.getColumnModel().getColumn(3).setResizable(false);
        ordersTable.getColumnModel().getColumn(3).setPreferredWidth(350);
        ordersTable.getColumnModel().getColumn(4).setResizable(false);
        ordersTable.getColumnModel().getColumn(4).setPreferredWidth(100);
        ordersTable.getColumnModel().getColumn(5).setResizable(false);
        ordersTable.getColumnModel().getColumn(5).setPreferredWidth(90);
        ordersTable.getColumnModel().getColumn(6).setResizable(false);
        ordersTable.getColumnModel().getColumn(6).setPreferredWidth(90);
        ordersTable.getColumnModel().getColumn(7).setResizable(false);
        ordersTable.getColumnModel().getColumn(7).setPreferredWidth(150);
        ordersTable.getColumnModel().getColumn(8).setResizable(false);
        ordersTable.getColumnModel().getColumn(8).setPreferredWidth(150);
        ordersTable.getColumnModel().getColumn(9).setResizable(false);
        ordersTable.getColumnModel().getColumn(9).setPreferredWidth(90);
        ordersTable.getColumnModel().getColumn(10).setResizable(false);
        ordersTable.getColumnModel().getColumn(10).setPreferredWidth(90);
        ordersTable.getColumnModel().getColumn(11).setResizable(false);
        ordersTable.getColumnModel().getColumn(11).setPreferredWidth(200);
        ordersTable.getColumnModel().getColumn(12).setResizable(false);
        ordersTable.getColumnModel().getColumn(12).setPreferredWidth(200);
        ordersTable.getColumnModel().getColumn(13).setResizable(false);
        ordersTable.getColumnModel().getColumn(13).setPreferredWidth(200);

        manageordersPanel.add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 1020, 330));

        searchordersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Search Order"));
        searchordersPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        searchorderCombox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "by Product Name", "by Date Posted", "by Customer Name" }));
        searchorderCombox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchorderComboxActionPerformed(evt);
            }
        });
        searchordersPanel.add(searchorderCombox, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 30, 140, -1));

        o_searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Zoom-icon (1).png"))); // NOI18N
        o_searchButton.setText("Search");
        o_searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                o_searchButtonActionPerformed(evt);
            }
        });
        searchordersPanel.add(o_searchButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 60, 140, -1));

        o_resetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Reload-icon.png"))); // NOI18N
        o_resetButton.setText("Reset View");
        o_resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                o_resetButtonActionPerformed(evt);
            }
        });
        searchordersPanel.add(o_resetButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 90, 140, -1));
        searchordersPanel.add(o_startdateField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 150, -1));
        searchordersPanel.add(ordersearchField, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 320, -1));

        manageordersPanel.add(searchordersPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 400, 570, 130));

        getContentPane().add(manageordersPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 95, 1100, 560));

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("GIOR-MI MARKETING CORPORATION");
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 20, 530, -1));

        jLabel7.setText("Inventory System");
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(640, 50, -1, -1));

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/hengbing.png"))); // NOI18N
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 10, -1, 70));

        managecustomersButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/User-Administrator-Green-iconbig.png"))); // NOI18N
        managecustomersButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                managecustomersButtonActionPerformed(evt);
            }
        });
        getContentPane().add(managecustomersButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, 100, 80));

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Manage Customers");
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 510, 100, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents


    public Object GetData(JTable table, int row_index){
        return table.getModel().getValueAt(row_index, 0);
    }

    private void manageproductsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageproductsButtonActionPerformed
        // TODO add your handling code here:
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("product"); i++){ // row count
            for (int x=0; x<productsTable.getColumnCount(); x++) // column count
                productsTable.setValueAt("", i, x);
        }
        manageproductsPanel.setVisible(true);
        managestocksPanel.setVisible(false);
        manageordersPanel.setVisible(false);
        managecustomersPanel.setVisible(false);

        viewProducts view = new viewProducts(this.productsTable);
        view.connect();
        view.viewProducts();
        view.disconnect();
    }//GEN-LAST:event_manageproductsButtonActionPerformed

    private void managestocksButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managestocksButtonActionPerformed
        // TODO add your handling code here:
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("stock"); i++){ // row count
            for (int x=0; x<stocksTable.getColumnCount(); x++) // column count
                stocksTable.setValueAt("", i, x);
        }
        manageproductsPanel.setVisible(false);
        managestocksPanel.setVisible(true);
        manageordersPanel.setVisible(false);
        managecustomersPanel.setVisible(false);

        stocksearchField.setVisible(true);
        datestocksearchField.setVisible(false);
        stocksearchCombox.setSelectedItem("by Product Name");

        viewStocks view = new viewStocks(this.stocksTable);
        view.connect();
        view.viewStocks();
        view.disconnect();
    }//GEN-LAST:event_managestocksButtonActionPerformed

    private void manageordersButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageordersButtonActionPerformed
        // TODO add your handling code here:
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("orderr"); i++){ // row count
            for (int x=0; x<ordersTable.getColumnCount(); x++) // column count
                ordersTable.setValueAt("", i, x);
        }
        manageproductsPanel.setVisible(false);
        managestocksPanel.setVisible(false);
        managecustomersPanel.setVisible(false);
        manageordersPanel.setVisible(true);

        o_startdateField.setVisible(false);
        searchorderCombox.setSelectedItem("by Product Name");

        viewOrders view = new viewOrders(this.ordersTable);
        view.connect();
        view.viewOrders();
        view.disconnect();
    }//GEN-LAST:event_manageordersButtonActionPerformed

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        exitFrame exitframe = new exitFrame(this);
        exitframe.setVisible(true);
    }//GEN-LAST:event_exitButtonActionPerformed

    private void searchorderComboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchorderComboxActionPerformed
        // TODO add your handling code here:
        if (searchorderCombox.getSelectedItem() == "by Customer Name" || searchorderCombox.getSelectedItem() == "by Product Name")
        {
            ordersearchField.setVisible(true);
            o_startdateField.setVisible(false);
            
        }
        else if(searchorderCombox.getSelectedItem() == "by Date Posted")
        {
            ordersearchField.setVisible(false);
            o_startdateField.setVisible(true);
        }
    }//GEN-LAST:event_searchorderComboxActionPerformed

    private void o_searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_o_searchButtonActionPerformed
        // TODO add your handling code here:
        if (searchorderCombox.getSelectedItem() == "by Product Name"){
            searchorder so = new searchorder(ordersearchField.getText(),"by Product Name",this.ordersTable);
            so.searchbypname();
            ordersearchField.setText("");
        }
        else if (searchorderCombox.getSelectedItem() == "by Customer Name"){
            searchorder so = new searchorder(ordersearchField.getText(), "by Customer Name",this.ordersTable);
            so.searchbycname();
            ordersearchField.setText("");
        }
        else if (searchorderCombox.getSelectedItem() == "by Date Posted"){
            searchorder so = new searchorder(o_startdateField.getText(),"by Date Posted",this.ordersTable);
            so.searchbydateposted();
            o_startdateField.setText("");
        }
}//GEN-LAST:event_o_searchButtonActionPerformed

    private void updateorderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateorderButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        if (ordersTable.getSelectedRow()==-1) {
            warningFrame wa = new warningFrame("updateerror", this);
            wa.setVisible(true);
        }
        else {
            oitemid = (Integer) GetData(ordersTable, ordersTable.getSelectedRow());
            itemid = oitemid.intValue();
            addOrder addorder = new addOrder(this, true, itemid);
            addorder.setTable(this.ordersTable);
            addorder.setVisible(true);
        }
}//GEN-LAST:event_updateorderButtonActionPerformed

    private void addorderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addorderButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        addOrder addorder = new addOrder(this, false, 0);
        addorder.setTable(this.ordersTable);
        addorder.setVisible(true);
}//GEN-LAST:event_addorderButtonActionPerformed

    private void addstockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addstockButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        addStock addstock = new addStock(this, false, 0);
        addstock.setTable(this.stocksTable);
        addstock.setVisible(true);
    }//GEN-LAST:event_addstockButtonActionPerformed

    private void updatestockButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatestockButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        if (stocksTable.getSelectedRow()==-1) {
            warningFrame wa = new warningFrame("updateerror", this);
            wa.setVisible(true);
        }
        else {
            oitemid = (Integer) GetData(stocksTable, stocksTable.getSelectedRow());
            itemid = oitemid.intValue();
            System.out.println("stockid:"+itemid);
            addStock addstock = new addStock(this, true, itemid);
            addstock.setTable(this.stocksTable);
            addstock.setVisible(true);
        }
    }//GEN-LAST:event_updatestockButtonActionPerformed

    private void addproductButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addproductButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        addProduct addproduct = new addProduct(this, false, 0);
        addproduct.setTable(this.productsTable);
        addproduct.setVisible(true);
    }//GEN-LAST:event_addproductButtonActionPerformed

    private void updateproductButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateproductButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);

        if (productsTable.getSelectedRow()==-1){
            warningFrame wa = new warningFrame("updateerror", this);
            wa.setVisible(true);
        }

        else {
            oitemid = (Integer) GetData(productsTable, productsTable.getSelectedRow());
            itemid = oitemid.intValue();
            addProduct addproduct = new addProduct(this, true, itemid);
            addproduct.setTable(this.productsTable);
            addproduct.setVisible(true);
        }
    }//GEN-LAST:event_updateproductButtonActionPerformed

    private void managecustomersButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managecustomersButtonActionPerformed
        // TODO add your handling code here:
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("customer"); i++){ // row count
            for (int x=0; x<customersTable.getColumnCount(); x++) // column count
                customersTable.setValueAt("", i, x);
        }
        manageproductsPanel.setVisible(false);
        managestocksPanel.setVisible(false);
        manageordersPanel.setVisible(false);
        managecustomersPanel.setVisible(true);
        viewCustomers view = new viewCustomers(this.customersTable);
        view.connect();
        view.viewCustomers();
        view.disconnect();
    }//GEN-LAST:event_managecustomersButtonActionPerformed

    private void searchproductButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchproductButtonActionPerformed
        // TODO add your handling code here:
        searchproduct sp = new searchproduct(productsearchField.getText(), activeproductsCheckbox.isSelected(), this.productsTable);
        sp.searchproductbyname();
        productsearchField.setText("");
    }//GEN-LAST:event_searchproductButtonActionPerformed

    private void s_searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_s_searchButtonActionPerformed
        // TODO add your handling code here:
         if(stocksearchCombox.getSelectedItem() == "by Product Name")
        { 
            searchstocks ss = new searchstocks(stocksearchField.getText(),"by Product Name",this.stocksTable);
            ss.searchbypname();
            stocksearchField.setText("");
        }
         else if(stocksearchCombox.getSelectedItem() == "by Date Posted")
         {
            searchstocks ss = new searchstocks(datestocksearchField.getText(), "by Date Posted", this.stocksTable);
            ss.searchbydateposted();
            datestocksearchField.setText("");
         }
}//GEN-LAST:event_s_searchButtonActionPerformed

    private void stocksearchComboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stocksearchComboxActionPerformed
        // TODO add your handling code here:
        if(stocksearchCombox.getSelectedItem() == "by Product Name")
        {
            stocksearchField.setVisible(true);
            datestocksearchField.setVisible(false);
        }
        else if(stocksearchCombox.getSelectedItem() == "by Date Posted")
        {
            stocksearchField.setVisible(false);
            datestocksearchField.setVisible(true);
        }
}//GEN-LAST:event_stocksearchComboxActionPerformed

    private void addcustomerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addcustomerButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        addCustomer addcustomer = new addCustomer(this, false, 0);
        addcustomer.setTable(this.customersTable);
        addcustomer.setVisible(true);
}//GEN-LAST:event_addcustomerButtonActionPerformed

    private void updatecustomerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updatecustomerButtonActionPerformed
        // TODO add your handling code here:
        this.setEnabled(false);
        if (customersTable.getSelectedRow() == -1) {
            warningFrame wa = new warningFrame("updateerror", this);
            wa.setVisible(true);
        }
        else {
            oitemid = (Integer) GetData(customersTable, customersTable.getSelectedRow());
            itemid = oitemid.intValue();
            addCustomer addcustomer = new addCustomer(this, true, itemid);
            addcustomer.setTable(this.customersTable);
            addcustomer.setVisible(true);
        }
    }//GEN-LAST:event_updatecustomerButtonActionPerformed

    private void searchcustomerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchcustomerButtonActionPerformed
        // TODO add your handling code here:
        searchcustomer sc = new searchcustomer(customersearchField.getText(),this.customersTable);
        sc.searchcustomerbyname();
        customersearchField.setText("");
    }//GEN-LAST:event_searchcustomerButtonActionPerformed

    private void s_resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_s_resetButtonActionPerformed
        // TODO add your handling code here:

        // clear table (ordertable)
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("stock"); i++){ // row count
            for (int x=0; x<ordersTable.getColumnCount(); x++) // column count
                ordersTable.setValueAt("", i, x);
        }

        viewStocks view = new viewStocks(this.stocksTable);
        view.connect();
        view.viewStocks();
        view.disconnect();
    }//GEN-LAST:event_s_resetButtonActionPerformed

    private void c_resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_c_resetButtonActionPerformed
        // TODO add your handling code here:

        // clear table
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("customer"); i++){ // row count
            for (int x=0; x<ordersTable.getColumnCount(); x++) // column count
                ordersTable.setValueAt("", i, x);
        }

        viewCustomers view = new viewCustomers(this.customersTable);
        view.connect();
        view.viewCustomers();
        view.disconnect();
    }//GEN-LAST:event_c_resetButtonActionPerformed

    private void presetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_presetButtonActionPerformed
        // TODO add your handling code here:
        // clear table
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("product"); i++){ // row count
            for (int x=0; x<ordersTable.getColumnCount(); x++) // column count
                ordersTable.setValueAt("", i, x);
        }

        viewProducts view = new viewProducts(this.productsTable);
        view.connect();
        view.viewProducts();
        view.disconnect();
    }//GEN-LAST:event_presetButtonActionPerformed

    private void o_resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_o_resetButtonActionPerformed
        // TODO add your handling code here:

        // clear table (ordertable)
        clearTable ct = new clearTable();
        for (int i=0; i<ct.erase("orderr"); i++){ // row count
            for (int x=0; x<ordersTable.getColumnCount(); x++) // column count
                ordersTable.setValueAt("", i, x);
        }

        viewOrders view = new viewOrders(this.ordersTable);
        view.connect();
        view.viewOrders();
        view.disconnect();
    }//GEN-LAST:event_o_resetButtonActionPerformed

    private void s_dwindlingButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_s_dwindlingButtonActionPerformed
        // TODO add your handling code here:
        searchstocks ds = new searchstocks(this.stocksTable);
        ds.dwindlingstocks();
    }//GEN-LAST:event_s_dwindlingButtonActionPerformed
  

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox activeproductsCheckbox;
    private javax.swing.JButton addcustomerButton;
    private javax.swing.JButton addorderButton;
    private javax.swing.JButton addproductButton;
    private javax.swing.JButton addstockButton;
    private javax.swing.JButton c_resetButton;
    private javax.swing.JTable customersTable;
    private javax.swing.JTextField customersearchField;
    private datechooser.beans.DateChooserCombo datestocksearchField;
    private javax.swing.JButton exitButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JButton managecustomersButton;
    private javax.swing.JPanel managecustomersPanel;
    private javax.swing.JButton manageordersButton;
    private javax.swing.JPanel manageordersPanel;
    private javax.swing.JButton manageproductsButton;
    private javax.swing.JPanel manageproductsPanel;
    private javax.swing.JButton managestocksButton;
    private javax.swing.JPanel managestocksPanel;
    private javax.swing.JButton o_resetButton;
    private javax.swing.JButton o_searchButton;
    private datechooser.beans.DateChooserCombo o_startdateField;
    private javax.swing.JTable ordersTable;
    private javax.swing.JTextField ordersearchField;
    private javax.swing.JButton presetButton;
    private javax.swing.JTable productsTable;
    private javax.swing.JTextField productsearchField;
    private javax.swing.JButton s_dwindlingButton;
    private javax.swing.JButton s_resetButton;
    private javax.swing.JButton s_searchButton;
    private javax.swing.JButton searchcustomerButton;
    private javax.swing.JPanel searchcustomersPanel;
    private javax.swing.JComboBox searchorderCombox;
    private javax.swing.JPanel searchordersPanel;
    private javax.swing.JButton searchproductButton;
    private javax.swing.JPanel searchproductsPanel;
    private javax.swing.JPanel searchstocksPanel;
    private javax.swing.JTable stocksTable;
    private javax.swing.JComboBox stocksearchCombox;
    private javax.swing.JTextField stocksearchField;
    private javax.swing.JButton updatecustomerButton;
    private javax.swing.JButton updateorderButton;
    private javax.swing.JButton updateproductButton;
    private javax.swing.JButton updatestockButton;
    // End of variables declaration//GEN-END:variables

}
